package com.wiz.weixin.controllor;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.wiz.weixin.common.ResponseCode;
import com.wiz.weixin.service.ModelMessageService;

/**
 * 消息处理接口，面对消费充值兑换
 */
@Controller
@RequestMapping("/message")
public class ModelMessageControllor implements ResponseCode{
	
	@Resource
	private ModelMessageService modelMessageService;
	
	/**
	 * 消费消息发送
	 * @param request
	 * @param response
	 * @param openId
	 * @param hqName
	 * @param stationName
	 * @param amount
	 * @param point
	 * @param blanceAmount
	 * @param balancePoint
	 * @param session
	 * @param model
	 * @return
	 */
	@RequestMapping(value="/consump")
	@ResponseBody
	public String fuellingMessage(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "openId") String openId,
			@RequestParam(value = "hqName") String hqName,
			@RequestParam(value = "stationName") String stationName,
			@RequestParam(value = "amount") String amount,
			@RequestParam(value = "point") String point,
			@RequestParam(value = "balanceAmount") String blanceAmount,
			@RequestParam(value = "balancePoint") String balancePoint,
			@RequestParam(value = "paidTypeName") String paidTypeName,
			@RequestParam(value = "createdTime") String createdTime,
			HttpSession session, Model model){
		modelMessageService.sendConsumpMessage(openId, hqName, stationName, amount, point, blanceAmount, 
				balancePoint,paidTypeName,createdTime);
		return DATA_OK;
	}
	
	@RequestMapping(value="/charge")
	@ResponseBody
	public String chargeMessage(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "openId") String openId,
			@RequestParam(value = "hqName") String hqName,
			@RequestParam(value = "stationName") String stationName,
			@RequestParam(value = "amount") String amount,
			@RequestParam(value = "giftAmount") String giftAmount,
			@RequestParam(value = "balanceAmount") String blanceAmount,
			@RequestParam(value = "createdTime") String createdTime,
			HttpSession session, Model model){
		modelMessageService.sendChargeMessage(openId, hqName, stationName, amount, blanceAmount,giftAmount, createdTime); 
		return DATA_OK;
	}
	
	@RequestMapping(value="/point")
	@ResponseBody
	public String exchangePointMessage(HttpServletRequest request,HttpServletResponse response,
			@RequestParam(value = "openId") String openId,
			@RequestParam(value = "hqName") String hqName,
			@RequestParam(value = "stationName") String stationName,
			@RequestParam(value = "point") String point,
			@RequestParam(value = "balancePoint") String balancePoint,
			@RequestParam(value = "createdTime") String createdTime,
			HttpSession session, Model model){
		modelMessageService.sendPointMessage(openId, hqName, stationName, point, balancePoint, createdTime); 
		return DATA_OK;
	}
}
